home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
ELECTRON
/
2687.ZIP
/
LS3.DOC
< prev
next >
Wrap
Text File
|
1990-06-25
|
26KB
|
673 lines
5.12 Macros - a way of simplifying logic network descriptions
When simulating complex logic systems it is essential to have a MACRO
facility which allows a previously defined logic network to be treated as a
module in its own right. Three basic ideas are central to the macro concept,
these are:-
(1) A macro is essentially a stand alone network description with the relevant
input and output nodes specified in the definition of the macro.
(2) Once defined, a macro can be treated as a functional BLACK BOX and can be
used over and over again just by referencing it by name. The LSYSTEM
compiler expands each macro which generates a list of the internal logic
components, ready for simulation.
(3) All circuit nodes defined within a macro definition are LOCAL, that is,
the actual node names used will not conflict with those used in the main
logic network or other macro definitions.
Each time a macro is invoked in the main logic network ( called like a
program subroutine ), UNIQUE versions of its internal node names are
automatically generated by the LSYSTEM compiler.
An unlimited number of macros can be defined for inclusion in logic network
descriptions. Macros can be nested up to 20 levels deep, that is macros can
use other macros, which use other macros, which use other macros etc .... up
to 20 levels.
5.12.1 Defining and using macros
Once a macro has been defined its use is identical to that of a primitive.
Four essential rules MUST be adhered to when defining and using macros:-
(1) A macro must be defined before it is used.
(2) A macro cannot be defined inside a macro definition.
However, other macros can be invoked from inside a macro definition.
(3) Clock primitives are NOT allowed within a macro definition.
(4) Command statements, for example .PRINT or .TIME, are not allowed
within a macro definition.
To define a macro the internal logic network description is placed between
the keywords .MACRO and .ENDM. The macro start directive .MACRO is followed
by a macro name, this is the macro reference name, and a list of interface
nodes. The macro definition ends with the end directive .ENDM. For
example, a very simple macro defining a AND_OR functional element is:-
+----+
A ---I & I
B ---I I--------+ AND_OR
+----+ I
+----+ I +----+
C ---I & I +----I >= I
D ---I I-------------I 1 I---------- F
+----+ +----+
I
I
I
+----------+
A -----I AND_OR I
B -----I I
C -----I I----- F
D -----I I
+----------+
In LSYSTEM syntax this macro could be written as:-
.MACRO AND_OR A B C D F
G1 A B N1 AND2
G2 C D N2 AND2
G3 N1 N2 F OR2
.ENDM
In this example definition nodes N1 and N2 are LOCAL internal nodes. The
AND_OR macro just defined could then be used in the main network description
or in another macro definition in exactly the same way as a primitive logic
component type would be.
Please note that when a macro is invoked ( called ), interface nodes are
parsed to it by POSITION and not by NAME.
For example, the main network description for a logic network using the
AND_OR macro twice, such as:-
+----------+
IN1 -----I AND_OR I
IN2 -----I I N1
IN3 -----I I-----+
IN4 -----I I I
+----------+ I +-----+
+------I & I
+----------+ +------I I------- OUTF
IN5 -----I AND_OR I I +-----+
IN6 -----I I I
IN7 -----I I-----+
IN8 -----I I N2
+----------+
would be described as:-
M1 IN1 IN2 IN3 IN4 N1 AND_OR
M2 IN5 IN6 IN7 IN8 N2 AND_OR
G1 N1 N2 OUT AND2
The network description defined above, using the AND_OR macro twice, could
itself have been defined as a macro, so that it could be treated as a
functional black box with eight inputs and one output. Hence, a macro called
AND_OR_2, which uses the macro AND_OR twice:-
+-----------+
A -----I AND_OR I
B -----I I-------+ AND_OR_2
C -----I I N1 I
D -----I I I
+-----------+ I +-----+
+----I & I
+-----------+ +----I I------- O
E -----I AND_OR I N2 I +-----+
F -----I I-------+
G -----I I
H -----I I
+-----------+
would be defined as:-
.MACRO AND_OR_2 A B C D E F G H O
M1 A B C D N1 AND_OR
M2 E F G H N2
G1 N1 N2 O
.ENDM
NOTE how the AND_OR macro has been NESTED within the AND_OR_2 macro. This
nesting process can be continued to 20 levels deep ( this example is just 1
level deep ) which should be more than adequate for most purposes.
The logic network description using the AND_OR macro twice, given earlier;
can now be defined in just one line, using the AND_OR_2 macro:-
M1 IN1 IN2 IN3 IN4 IN5 IN6 IN7 IN8 OUT AND_OR_2
Once expanded out by the LSYSTEM compiler, the resulting network description
will be no different to that generated by not using macros and the logic
network repetitively described with logic primitives.
Macro nested definitions or recursive calls are NOT allowed., for example:-
CORRECT WRONG
.macro one a b .macro two a b
g1 n1 n1 a nand2 .macro one c d
g2 a b n1 nor2 g1 n1 n1 c nand2
.endm g2 a b n1 nor2
.macro two a b .endm
g3 a b n xor g3 a b n xor
g4 a b one g4 n b one
.endm .endm
A final feature of macros worth remembering when defining a macro concerns
the rise and fall time of different paths through the internal logic network.
In general each path will have a different rise and fall time, for example in
a D flip flop the D to Q path is likely to be different to the PRESET or
CLEAR to Q path. The individual delay times can be set by including, within
a macro structure, non-inverting buffers with their rise and fall times set
to give the correct overall path delays. The following example illustrates
the technique:-
* Asynchronous BCD counter.
.LIB default.LIB
*
.macro jkff_cp_ne j clock k clear qn q preset
g1 clock clockn INV (delay = 3)
ic1 clockn clear preset j k q qn jkff_cp_pe
.endm
.MACRO DECODE Q1 Q2 Q3 Q4 DOUT
G1 Q1 O1 INV DELAY=1
G3 Q3 O3 INV DELAY=1
G5 O1 Q2 O3 Q4 DOUT NAND4 (DELAY=6)
.ENDM
*
GEN1 COUNT CLK0 100
GEN2 CLOCK CLK0 PERIOD(200)
GEN3 PRESET CLK1 PERIOD(50000)
*
IC1 COUNT CLOCK COUNT CLR NQ1 Q1 PRESET JKFF_CP_NE
IC2 COUNT Q1 COUNT CLR NQ2 Q2 PRESET JKFF_CP_NE
IC3 COUNT Q2 COUNT CLR NQ3 Q3 PRESET JKFF_CP_NE
IC4 COUNT Q3 COUNT CLR NQ4 Q4 PRESET JKFF_CP_NE
IC5 Q1 Q2 Q3 Q4 CLR DECODE
*
.TIME 7000 7000
.PRINT COUNT PRESET CLR CLOCK Q1 Q2 Q3 Q4
.END
5.13 Comments
Comments can be embedded into the logic network description file by beginning
the line they occupy with an asterisk ( * ). Comments can also be appended
to any line by preceding them with a semi-colon ( ; ). Note that appended
comments are not passed on to any output files, whereas * delimited comments
are. Comments are simply ignored by the compilation stage of the simulation
cycle.
A comment line, after the delimiter, may contain any valid alphanumeric
string, for example:-
*--- Network description of a 16bit shift register.
*--- Using D type flip flops.
;++ THIS COMMENT WILL NOT BE PASSED TO THE OUTPUT FILES.
*--- Default primitive library loaded.
.lib default; This is an appended comment.
*--- Macro library loaded via include statement.
.include default.mac
*--- Excitation clocks.
clo1 clock clk0 period(100) ; system clock with 100ns period.
clo2 reset clk1 523 577 ; short pulse to initialize shift register stages.
clo3 enable clk0 ; tri state output enable.
*--- Network description
.
.
etc etc
6. Compiling a logic network description
6.1 The compile command
Once the network description file has been created, using a text editor, the
description must be COMPILED into a pure data format ready for input to the
LSYSTEM simulator. Compilation, as detailed in section 4.2, is initiated by
entering:-
C:\LSYSTEM> compile file[.NWK] [switches......] <ENTER>
6.2 Error and warning messages reported during compilation
Some fatal errors, such as inability to open the specified network
description file or insufficient memory available, just display an error
message saying as such and abort compilation. Most minor errors and
warnings however, do not abort compilation immediately. Warnings and errors
are added up during the first pass of the compiler and a decision is made on
whether to execute the second ( final ) pass or not.
Errors and warnings are reported on the video screen and written to the
".LST" file if requested by:-
- Printing the line number and the file error found.
- Printing the line in error, with the error highlighted.
- Printing a arrowhead underneath the error for clarity.
An example error is:-
0115 <4SHIFT.NWK> "Numerical value invalid"
G10 OE OE1 INV RISE=1O FALL=8
This error has been reported because the O used for the 1O is actually an
letter O ( as in N, O, P, Q etc ) and not a number zero ( as in 0, 1 ,2 etc).
All error and warning message output is duplicated in the same format in the
".LST" error listing, when requested by a -L or a .LST command.
6.3 The information file -- file.INF
An information file with the extension ".INF" is always generated during the
compilation phase of the LSYSTEM simulation cycle. This output file gives
information about the logic network statistics, including the number of nodes
, logic components, number of primitives loaded and so forth.
After an error free compilation the information file contains:-
- Network description name.
- Number of source lines compiled.
- Number of nodes in network.
- Number of trace nodes.
- Number of logic components in network.
- Number of excitation clocks.
- Simulation length.
- Simulation display period.
- Number of primitives loaded.
- Number of macros loaded.
- Number of used macros.
- Highest macro nesting.
- Complete node name table, with internal node numbers.
- Table of used primitives, with number of times used.
- Table of used macros, with internal reference numbers.
The information file can be used in conjunction with any warnings generated
at the simulation phase of the LSYSTEM simulation cycle to trace contending
nodes, and undriven ( floating ) inputs. Warnings reported at the
simulation stage reference nodes and logic elements by their internal numbers
and not by name, so this file is invaluable.
7. Simulating a digital logic network
7.1 Prerequisites
A logic network description file must have been created and an error free
compilation performed to generate the necessary data files needed by the
simulation stage of the LSYSTEM simulation cycle.
Simulate the network as specified in section 4.3 by entering:-
C:\LSYSTEM> simulate file <ENTER>
7.2 Interpreting the tabular results file -- file.RLT
The primary output file generated by a simulation has the extension ".RLT"
and contains tabulated information representing each trace node change, with
reference to time in nS. Node states are output in the results file EITHER:
at the simulation display period time specified in the network description,
OR whenever the logical state of a trace node changes, see section 5.11.
Trace nodes are shown with four possible states:-
0 -> Logical LOW.
1 -> Logical HIGH.
Z -> High impedance state.
X -> Indeterminate state ( startup or contention condition).
Warnings generated at simulation time are embedded within the node state
table as and when they occur.
7.3 Errors and warnings reported at simulation time
Errors and warnings generated at simulation time are minimal, since many of
the problems causing errors, such as undriven nodes, are removed at
compilation stage in the LSYSTEM simulation cycle.
The warnings, with a typical example, that are reported are:-
(1) Output contention
* WARNING [17nS] - Output contention: Node 40 , f49 f67
Reports that two logic components are trying to drive node number 40 into
opposing states.
(2) Floating input node
* WARNING [100nS] - Floating input node: f71 {JKFF_CP_NE}, N40
Reports that node 40 has gone into high impedance state and has caused an
input on a JK flip flop to float high.
(3) Simulation manually aborted
* WARNING - Simulation manually aborted at time : 3053nS
Reports simulation aborted by pressing <ESC>. The results up to this point
are still valid.
(5) A node never assumed a logical state
* Warning - Node number 5 never assumed a logical state
This warning, for every node applicable, is given at the end of the results
listing. It means that the node stayed in the indeterminate state X
throughout the entire simulation period. The logic element(s) driving the
node were either never excited by a changing input node, or remained in
contention the whole time. Contention though would have been reported as
above, when it occurred.
(6) Network instability
In the case of a logic network which is unstable, LSYSTEM reports the time at
which the instability occurred, on screen in a separate window, then finishes.
8. Post simulation graphics processing of trace node waveforms
8.1 Prerequisites
The network description must have been compiled and simulated successfully
and your computer must include one of the graphics adapters specified in
section 2. The waveform graphics post processor, as described in detail in
section 4.4, is initiated by entering:-
C:\LSYSTEM> waveform file [switches....] <ENTER>
8.2 Split screen display
The graphical display starts in split screen mode. The top half of the
screen contains a timing diagram format display of the results data, whilst
the bottom contains a window displaying the tabular results file. This
allows direct comparison of both forms of data presentation. The split
screen mode can be toggled on and off using function key F2 whilst being
displayed. The tabular results file is loaded by waveform into a buffer at
the start of a display session. If the results file is greater in size than
this buffer only those results which will fit in the buffer are loaded by
waveform. The parameters in the .TIME statement should be changed if this
occurs.
8.3 Waveform logic state presentation
Four logical states are shown on the graphical display, they are:-
....XXXXXXX........ Pulse of HIGH Impedance state [RED].
....XXXXXXX........ Pulse of Indeterminate state [GREEN].
.......
.... .......... Pulse of HIGH state.
.... ........... Pulse of LOW state.
......
these state notations are equivalent to the Z, X, 1 and 0 notation used for
the tabulated results file. Trace node states are represented using the
above notation in a graph format, plotting time ( in for example nS )
horizontally, against specified trace nodes vertically.
Several user commands are available interactively whilst viewing the
graphical results. They are are listed in the following screen dump of the
waveform help screen.
SEE PRINTED USER GUIDE FOR SCREEN DUMP
[ OR YOUR COMPUTER SCREEN ]
9. A further example simulation
To demonstrate the processes discussed in earlier sections of this manual, a
commented example network is presented next. The network description file
for this example is also included on the LSYSTEM master disks. The example
has been chosen to demonstrate as wide a range of the available LSYSTEM
functions as possible. Functionally, the sample network describes an 8 bit
serial data transmitter. Eight data bits are loaded and the transmitted as
an 11 bit serial data stream which has one start bit and two stop bits.
+--------------------+
B1 ---------I I
B2 ---------I I--------- OUTM
B3 ---------I I
B4 ---------I I
B5 ---------I I
B6 ---------I I
B7 ---------I I
B8 ---------I I
I I
LOAD --------OI I
TRANS --------OI I
RESET --------OI I--------- BUSY
CLOCK ---------I I
+--------------------+
The operation of the transmitter is as follows:-
1- Reset by holding RESET low for a short period.
Reset state for transmitter output is logic 1.
2- Latch parallel data in by taking LOAD low for at least one clock
cycle (loads on rising edge).
3- Pulse TRANSMIT low to send 11 bit serial data, at bit rate = clock / 2,
made up as follows :-
0XXXXXXXX11
where 0 = start bit,
X = data bits,
and 1 = stop bits.
4- BUSY remains high whilst serial data is being transmitted.
5- TRANSMIT ignored during BUSY period.
6- LOAD ignored during BUSY period.
7- RESET clears asynchronously whenever applied.
8- A new LOAD/TRANSMIT sequence can occur as soon as BUSY
returns to an inactive (logic 0 ) state.
9.1 The transmitter network file -- SAMPLE.NWK
The sample network description file should be studied until all the important
factors are understood. Note the way in which the logic network has been
broken down into manageable portions with the use of macros.
* SAMPLE.NWK example file -- 8 bit serial data transmitter.
*
.lib default.lib; ** Standard SHAREWARE PRIMITIVES **
*
elc clocks CLK0 PERIOD(100) ; Main system clock.
elc reset CLK1 323 379 ; Single RESET pulse to initialise counter.
elc trans clk1 1023 1523 2720 2803
*------------------------------------- transmit input pulse -- for sending
*------------------------------------- data.
elc load CLK1 577 777 2423 2533
*----------------------------- Load pulse -- for loading parallel data.
elc B1 clk1 2400 ; Parallel data -- bit 1
elc B2 clk1 2400 ; bit 2
elc B3 clk0 2400 ; bit 3
elc B4 clk0 2400 ; bit 4
elc B5 clk0 2400 ; bit 5
elc B6 clk1 2400 ; bit 6
elc B7 clk1 2400 ; bit 7
elc B8 clk1 2400 ; bit 8
elc vcc clk1 ; V+ power rail.
elc gnd clk0 ; zero volt power rail.
*-- 4 bit ring counter. Resetting to 1000
*-- sequence:
* 1000
* 0100
* 0010
* 0001
* 1000
* etc....
*
.macro 12ring clock reset qa qb qc qd qe qf qg qh qi qj qk ql vcc
el_ring clock vcc reset l a na dff_cp_pe (rise=12 fall=13)
el_ring clock reset vcc a b nb dff_cp_pe (rise=12 fall=13)
el_ring clock reset vcc b c nc dff_cp_pe (rise=12 fall=13)
el_ring clock reset vcc c d nd dff_cp_pe (rise=12 fall=13)
el_ring clock reset vcc d e ne dff_cp_pe (rise=12 fall=13)
el_ring clock reset vcc e f nf dff_cp_pe (rise=12 fall=13)
el_ring clock reset vcc f g ng dff_cp_pe (rise=12 fall=13)
el_ring clock reset vcc g h nh dff_cp_pe (rise=12 fall=13)
el_ring clock reset vcc h i ni dff_cp_pe (rise=12 fall=13)
el_ring clock reset vcc i j nj dff_cp_pe (rise=12 fall=13)
el_ring clock reset vcc j k nk dff_cp_pe (rise=12 fall=13)
el_ring clock reset vcc k l nl dff_cp_pe (rise=12 fall=13)
el_ring nl a qa and2 (delay=9)
el_ring na b qb and2 (delay=9)
el_ring nb c qc and2 (delay=9)
el_ring nc d qd and2 (delay=9)
el_ring nd e qe and2 (delay=9)
el_ring ne f qf and2 (delay=9)
el_ring nf g qg and2 (delay=9)
el_ring ng h qh and2 (delay=9)
el_ring nh i qi and2 (delay=9)
el_ring ni j qj and2 (delay=9)
el_ring nj k qk and2 (delay=9)
el_ring nk l ql and2 (delay=9)
.endm
*
.macro 12BURST clock reset XMIT a b c d e f g h i j k l active vcc
*-- Generates set of enable pulses for conversion
*-- of parallel data to serial stream.
el_12burst reset n1 n2 and2 (delay = 9)
el_12burst xmit n5 inv (delay = 9)
el_12burst n5 n4 n7 or2 (delay = 9)
el_12burst clock nclock inv (delay = 9)
el_12burst n4 nclock n3 and2 (delay = 9)
el_12burst L n1 inv (delay = 9)
el_12burst clock n2 vcc n7 n4 not_n4 dff_cp_pe (delay = 9)
el_12burst N3 N4 a b c d e f g h i j k l vcc 12ring
el_12burst a active inv (delay = 9)
.endm
.macro 8LATCH clock reset Nload a b c d e f g h fa fb fc fd fe ff fg fh vcc
*-- Nload LOW causes data to be latched in at next rise clk edge.
*-- Data can be read always from outputs.
el_8latch nload not_1 inv (delay = 9)
el_8latch not_1 clock clk and2 (delay = 9)
el_8latch clk reset vcc a fa not_fa dff_cp_pe (rise=12 fall=13)
el_8latch clk reset vcc b fb not_fb dff_cp_pe (rise=12 fall=13)
el_8latch clk reset vcc c fc not_fc dff_cp_pe (rise=12 fall=13)
el_8latch clk reset vcc d fd not_fd dff_cp_pe (rise=12 fall=13)
el_8latch clk reset vcc e fe not_fe dff_cp_pe (rise=12 fall=13)
el_8latch clk reset vcc f ff not_ff dff_cp_pe (rise=12 fall=13)
el_8latch clk reset vcc g fg not_fg dff_cp_pe (rise=12 fall=13)
el_8latch clk reset vcc h fh not_fh dff_cp_pe (rise=12 fall=13)
.endm
*
.macro TriSbuf in enable out
el_TriSbuf enable Nenable inv
el_TriSbuf nenable in out tbuf
.endm
*
*-- Transmitter
*
el clockS reset trans +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 ACT vcc 12burst
el gnd +2 out triSbuf
el a +3 out triSbuf
el b +4 out triSbuf
el c +5 out triSbuf
el d +6 out triSbuf
el e +7 out triSbuf
el f +8 out triSbuf
el g +9 out triSbuf
el h +10 out triSbuf
el vcc +11 out triSbuf; ** Stop 1 **
el vcc +12 out triSbuf; ** Stop 2 **
el vcc +1 out triSbuf
*
el clockS NclockS inv (delay = 1)
el NclockS vcc reset out outM not_outM dff_cp_pe; REALLY "SET" not reset.
el clockS reset vcc active busy not_busy dff_cp_pe
el vcc out res; ** Pull up TRi-STATE o/ps **
el clockS NCw inv (delay = 0)
el NCw NCu inv (delay = 1)
el NCw NCu ref and2 (delay = 1)
el clockS reset load b1 b2 b3 b4 b5 b6 b7 b8 a b c d e f g h vcc 8latch
*
*
.expand
.time 10000 10000
.print clockS reset ! load ! transmit ! ref ! busy !!!! outm !!!!!!
.print bit1 bit2 bit3 bit4 bit5 bit6 bit7 bit8
.end
Appendix A Installing LSYSTEM on floppy disks
LSYSTEM is a disk intensive suite of computer programs. If the computer you
are using has a hard disk or a high density floppy disk fitted then NO
problems with lack of disk space are likely to occur. For users with only
360K DSDD floppy drives installed in their computer it is still possible to
run LSYSTEM but care must be taken over the available disk space.
To install LSYSTEM on a 360K floppy disk system the following steps are
recommended:-
(1) Format a new 360K floppy disk.
(2) Make a directory called LSYSTEM on the formatted disk.
(3) Copy the following files from the LSYSTEM master disks to the LSYSTEM
directory on the 360k floppy.
COMPILE.EXE LSM.BAT CGA.BGI
SIMULATE.EXE LS.BAT EGAVGA.BGI
WAVEFORM.EXE HERC.BGI
DEFAULT.LIB
You should find these files require slightly over 191K bytes of disk
space.
(4) Add to these files the example network file SAMPLE.NWK.
The 360K floppy is now a working LSYSTEM disk which can be used in either the
A or B drives. To use the LSYSTEM in the B drive, make the B drive the
current drive and change directories to the LSYSTEM directory. This allows
LSYSTEM to be run by entering, for example
B:\LSYSTEM> LSM SAMPLE, or
B:\LSYSTEM> LS SAMPLE
The example file SAMPLE.NWK, see page 38, generates a number of files which
require roughly 58K of disk space, leaving room on a 360K floppy for a number
of other library and macro files. Take care not to exceed the available free
disk space by requesting large quantities of output results with badly chosen
.TIME statement parameters.
Appendix B The LSYSTEM primitive library file structure
ONLY AVAILABLE TO REGISTERED LSYSTEM USERS
Appendix C LSYSTEM RAM primitives
ONLY AVAILABLE TO REGISTERED LSYSTEM USERS
Appendix D ROM primitives
ONLY AVAILABLE TO REGISTERED LSYSTEM USERS